package com.china.zhuoyue.ui.base

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.china.zhuoyue.ui.listener.OnCheckBean

abstract class BaseMultipleCheckAdapter<VH : RecyclerView.ViewHolder, B : OnCheckBean> : BaseRecyclerAdapter<VH, B>() {
    fun getChecks(): MutableList<B> = mutableListOf<B>().apply {
        for (item in datas) {
            if (item.check()) add(item)
        }
    }

    // 多选
    override fun subOnClickAdapter(v: View, position: Int) {
        val item = getItem(position)
        item.changeCheck(!item.check())
        notifyItemChanged(position)
    }
}